article.help
  carousel.deck.container-fluid
    slide.row-fluid.summary
      .summary.col-sm-3
        h3 Query Plan
        p.lead Understand what cypher is doing
      .details.col-sm-5
        p
          | Cypher breaks down the work of executing a query into small pieces called&nbsp;
          em operators
          | . Each operator is responsible for a small part of the overall query.
          | The operators are connected together in a pattern called a Query Plan.
        p
          | When you use the&nbsp;
          a(help-topic='explain') EXPLAIN
          |  or&nbsp;
          a(help-topic='profile') PROFILE
          |  commands, Neo4j Browser displays a diagram of the Query Plan.
        p
          | Click the right arrow button for the later pages of this guide,
          | which explain how to read the Query Plan diagram.
      .details.col-sm-4
        img.img-responsive.pull-right(src='images/query-plan.svg')
    slide.row-fluid
      .details.col-sm-5
        img.img-responsive(src='images/query-plan-operator-rows.svg')
      .details.col-sm-7
        h4 Operators
        p
          | Each Operator is displayed as a rectangle with its name in
          | the top-left corner. See the&nbsp;
          a(href='{{ neo4j.version | neo4jDeveloperDoc }}/#execution-plans') operators manual page
          |  for a description of what each operator does.
        h4 Pipes
        p
          | Operators are connected by pipes; each pipe represents the output of
          | one operator and the input of the next.
        h4 Rows
        p
          | In Query Plan diagrams, the width of a pipe indicates the number
          | of rows that pass between operators. This means that by looking at the
          | overall diagram, you can quickly see the&nbsp;
          em shape
          |  of the query, in terms of which parts process lots of rows,
          | and which parts process few.
        h4 Estimated rows
        p
          | When you use the&nbsp;
          a(help-topic='explain') EXPLAIN
          |  keyword, the query is not actually executed; so it's not possible to show actual number
          | of rows for each pipe. In this case, the Query Plan diagram shows&nbsp;
          em estimated rows
          |  instead. These numbers are predicted based on Neo4j's built-in
          | statistics. The Cypher cost-based planner uses estimated rows to determine
          | the optimal query plan.
    slide.row-fluid
      .details.col-sm-5
        img.img-responsive(src='images/query-plan-operator-cost.svg')
      .details.col-sm-7
        h4 Database hits
        p
          | Each operator will ask the Neo4j storage engine to do work such as retrieving or updating data.
          | A&nbsp;
          em database hit
          |  is an abstract unit of this storage engine work.
        p
          | When you use the&nbsp;
          a(help-topic='profile') PROFILE
          | command, the footer of the result frame displays the total number of database hits incurred
          | while running the query.
          | By comparing this total for different query plans, you can tell which one is better
          | in terms of work for the storage engine.
        p
          | In addition of the total number of database hits, the Query Plan diagram shows
          | the database hits for each individual operator. For operators with a large number
          | of database hits, there is a red box underneath the operator, with its height
          | proportional to the number.  This means that you can glance very quickly at the whole
          | Query Plan diagram and spot the operators that are responsible for significant storage engine work.
    slide.row-fluid
      .details.col-sm-5
        img.img-responsive(src='images/query-plan-operator-details.svg')
      .details.col-sm-7
        h4 Click to expand
        p
          | Some operators can reveal more information about what they are doing.
          | If you see a triangular expand icon next to the operator name,
          | you can click to expand the operator and reveal some more details.
          | When you're done, you can click the header again to collapse the operator
          | and hide the details.
        p
          | If you want to quickly expand all the operators, there are expand-all&nbsp;
          i.fa.fa-caret-square-o-down
          |  and collapse-all&nbsp;
          i.fa.fa-caret-square-o-up
          |  buttons below the diagram.
        h4 Identifiers
        p
          | The first section of details lists the identifiers that the operator works with.
          | if you've named identifers in your query, e.g.&nbsp;
          code MATCH (n)
          |  then you should find the identifier n bound in one of the operators.
          | In addition to identifiers that you named in your query you may see
          | some internal identifiers that Cypher has introduced to keep track
          | of unnamed entities.
        h4 Expressions
        p
          | After the identifiers, you'll see a section for an expression.
          | This is commonly a boolean expression such as&nbsp;
          code hasProp(born)
          |  or it can be a graph pattern to be expanded such as&nbsp;
          code ()-[r]-()
        p
          table.table-condensed.table-help
            tr
              th Reference:
              td
                code
                  a(href='{{ neo4j.version | neo4jDeveloperDoc }}/#execution-plans') Execution Plans
                |  manual page
            tr
              th Related:
              td
                a(help-topic='explain') :help EXPLAIN
                | &nbsp;
                a(help-topic='profile') :help PROFILE
                | &nbsp;
